using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;

namespace EventLogMailer
{
    public static class PathUtils
    {
        public static string ResolveApplicationExecutableRelative(string path)
        {
            var assemblyLocation = Assembly.GetExecutingAssembly().Location;
            var assemblyDirectory = Path.GetDirectoryName(assemblyLocation);
            Debug.Assert(assemblyDirectory != null, "assemblyDirectory != null");

            return Path.Combine(assemblyDirectory, path);
        }

        public static string ResolveApplicationDataRelative(string path)
        {
            return Path.Combine(ApplicationDataDirectory, path);
        }


        public static string ApplicationDataDirectory
        {
            get
            {
                var applicationDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                return Path.Combine(applicationDataDirectory, typeof(ApplicationState).Assembly.GetName().Name);
            }
        }
    }
}